package com.maserb.monitor.dataCenter.communication;

import lombok.Data;

import java.util.ArrayList;
import java.util.List;

@Data
public class EigenValueNetPackage {
    private String deviceCode;
    private int recordCount;
    private List<EigenValueRecord> eigenvalueRecords;

    public static EigenValueNetPackage convert(byte[] content) {
        EigenValueNetPackage p = new EigenValueNetPackage();
        Box<Integer> index = new Box<Integer>(0);
        Integer count = 8;
        p.deviceCode = ByteUtils.getString(content, index, count);
        p.recordCount = ByteUtils.getInt(content, index);
        p.eigenvalueRecords = new ArrayList<EigenValueRecord>();
        for (int i = 0; i < p.recordCount; i++) {
            EigenValueRecord record = EigenValueRecord.convert(content, index);
            p.eigenvalueRecords.add(record);
        }

        return p;
    }
}
